package com.frogs.ucenter.v1.request;

import java.math.BigDecimal;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.util.StringUtil;
import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

/**
 * 冻结余额请求类
 * @author hongyuhao
 *
 */
public class UserRechargeBalanceBlockingRequest extends Request {
	
	private static final long serialVersionUID = -9118302732962179601L;
	
	private int userId ;
	
	private String orderId;
	
	private BigDecimal consumeMoney;
	
	private String code;
	
	private String ip;
	

	/** */
	public UserRechargeBalanceBlockingRequest() {
	}

	@Override
	public void parse(HttpServletRequest request) {
		
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), -1);
		this.orderId = requestInfo.getParameter(ApiUrlParamEnum.orderId.getParamName());
		this.consumeMoney = requestInfo.getBigDecimalParameter(ApiUrlParamEnum.consumeMoney.getParamName());
		this.code = requestInfo.getParameter(ApiUrlParamEnum.code.getParamName());
		this.ip = requestInfo.getParameter(ApiUrlParamEnum.ip.getParamName());
		
		
		if( userId < 0) {
			throw new RequestIllegalException("用户ID不能为空");
		}
		
		if(StringUtil.isEmpty(orderId)) {
			throw new RequestIllegalException("订单号不能为空");
		}
		
		if(StringUtil.isEmpty(code)) {
			throw new RequestIllegalException("验证码不能为空");
		}
		
		if(null == consumeMoney || BigDecimal.valueOf(0).compareTo(consumeMoney) == 0 || BigDecimal.valueOf(0).compareTo(consumeMoney) == 1) {
			throw new RequestIllegalException("非法的金额");
		}
		
	}
	
	public int getUserId() {
		return userId;
	}
	
	public void setUserId(int userId) {
		this.userId = userId;
	}

	public String getOrderId() {
		return orderId;
	}

	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}

	public BigDecimal getConsumeMoney() {
		return consumeMoney;
	}

	public void setConsumeMoney(BigDecimal consumeMoney) {
		this.consumeMoney = consumeMoney;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}
	
	
	

}
